<template>
  <div class="tableList">
    <div class="table">
      <el-table stripe resizable :border="true" :data="listData" height="100%">
        <template #empty>
          <el-empty description="暂无数据" />
        </template>
        <el-table-column prop="subCode" show-overflow-tooltip label="部件编号" width="140" />
        <el-table-column prop="subName" show-overflow-tooltip label="部件名称" width="140" />
        <el-table-column prop="specSubName" show-overflow-tooltip label="规格" width="140" />
        <el-table-column prop="subBarCode" show-overflow-tooltip label="部件条码" width="140" />

        <el-table-column prop="goodsType" show-overflow-tooltip label="类型" width="100">
          <template #default="{ row }">
            {{ row.goodsType == 1 ? '成品' : '配件' }}
          </template>
        </el-table-column>
        <el-table-column prop="subQty" show-overflow-tooltip label="批号" width="100" />
        <el-table-column prop="subUnit" show-overflow-tooltip label="单位" width="100" />
      </el-table>
    </div>
    <div class="pagination">
      <!-- <Pagination
          ref="pageRef"
          :list_total="total"
          @size-change="changeSize"
          @current-change="currentChange"
        /> -->
    </div>
  </div>
</template>

<script setup lang="ts">
  import { ref, onMounted, reactive } from 'vue'
  import { useRoute } from 'vue-router'
  import { ElMessageBox } from 'element-plus'
  import { mountingsList } from '@/api/code'

  const props = defineProps({
    code: {
      type: String,
      default: () => '',
    },
  })

  const listData = ref([])
  const total = ref(0)
  // const pageRef = ref()
  // const form = {
  //   page: 1,
  //   limit: 10
  // }
  // const changeSize = () => {
  //   form.page = pageRef.value.current
  //   getList()
  // }
  // const currentChange = () => {
  //   form.limit = pageRef.value.size
  //   getList()
  // }
  const route = useRoute()
  const emits = defineEmits(['success'])
  const getList = () => {
    mountingsList(props.code).then((res) => {
      if (res.data.code == 20000) {
        listData.value = res.data.data
        // total.value = Number(res.data.data.total) || 0
        emits('success')
      } else {
        ElMessageBox({
          message: res.data.message,
          type: 'error',
          title: '提示',
        })
      }
    })
  }
  onMounted(() => {
    getList()
  })
</script>

<style lang="scss" scoped></style>
